/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.sip.util;

/**
 *
 * @author sriram
 */
public enum eSipHeader {
    NIL(0, ""),
    VIA(1, "Via: "),
    ACCEPT(2, "Accept: "), 
    ACCEPT_ENCODING(3,"Accept-Encoding: "), 
    ACCEPT_LANG(4, "Accept-Language: "), 
    CALLID(5, "Call-ID: "), 
    CONTACT(6, "Contact: "), 
    CSEQ(7, "CSeq: "),
    DATE(8, "Date: "),
    ENCRYPTION(9, "Encryption: "),
    EXPIRES(10, "Expires: "),
    FROM(11, "From: "),
    RECORD_ROUTE(12, "Record-Route: "),
    TIMESTAMP(13, "Timestamp: "),
    TO(14, "To: "),
    CONTENT_ENCODING(15, "Content-Encoding: "), 
    CONTENT_LENGTH(16, "Content-Length: "),
    CONTENT_TYPE(17, "Content-Type: "),
    AUTHORIZATION(18, "Authorization: "), 
    HIDE(19, "Hide: "), 
    MAX_FORWARDS(20, "Max-Forwards: "), 
    ORGANIZATION(21, "Organization: "), 
    PRIORITY(22, "Priority: "),
    PROXY_AUTH(23, "Proxy-Authentication: "),
    PROXY_REQ(24, "Proxy-Require: "),
    ROUTE(25, "Route: "),
    REQUIRE(26, "Require: "),
    RESPONSE_KEY(27, "Response-Key: "),
    SUBJECT(28, "Subject: "),
    USER_AGENT(29, "User-Agent: "),
    ALLOW(30, "Allow: "), 
    PROXY_AUTHENTICATE(31,"Proxy-Authenticate: "), 
    RETRY_AFTER(32, "Retry-After: "), 
    SERVER(33, "Server: "), 
    UNSUPPORTED(34, "Unsupported: "), 
    WARNING(35, "Warning: "),
    WWW_AUTH(36, "WWW-Authenticate: ");
    
    private final int index;
    private final String str;
    
    eSipHeader(int index, String string) {
        this.index = index;
        this.str = string;
    }
    
    public int toInt() {
        return index;
    }
 
    @Override
    public String toString() {
        return str;
    }

    public static eSipHeader fromInt(int id) {
        for (eSipHeader head : eSipHeader.values()) {
            if(head.toInt() == id)
                return head;
        }
        return NIL;
    }

    public static eSipHeader fromString(String headerName) {
        headerName = headerName.trim().toLowerCase();
        for (eSipHeader head : eSipHeader.values()) {
            if(headerName.equals(head.toString().trim().toLowerCase()))
                return head;
        }
        return NIL;
    }
}
